package dimensional.traveler.client.ui.util;

import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.box.MessageBox;

public class MessagePopup {

	private static AlertMessageBox serverErrorMessageBox = new AlertMessageBox("Server error", null);
	private static AlertMessageBox userErrorMessageBox = new AlertMessageBox("User error", null);
	private static MessageBox infoMessageBox = new MessageBox("");
	
	static {
		infoMessageBox.setPredefinedButtons(PredefinedButton.OK);
		infoMessageBox.setIcon(MessageBox.ICONS.info());
	}
	
	public static void displayServerError(Throwable throwable){
		serverErrorMessageBox.setMessage(throwable.getMessage());
        serverErrorMessageBox.show();
	}
	
	public static void displayUserError(String message){
		userErrorMessageBox.setSize("335px", "115px");
		userErrorMessageBox.setMessage(message);
		userErrorMessageBox.show();
	}
	
	public static void displayInfoMessage(String heading, String message){
		infoMessageBox.setHeadingText(heading);
		infoMessageBox.setMessage(message);
		infoMessageBox.show();
	}
}
